package com.job.yangshida.homework0707.lizi0707.oop1;

/**
 * @author 杨士达
 * @version 1.0
 * @since 2022-07-08 19:00:30
 */
public class Employee {
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age<18||age>60){
            System.out.println("赋值错误");
            return;
        }
        this.age = age;
    }

    //this指当前对象 构造方法里指正在创建的对象
    //--------------成员方法里指调用这个方法的那个类
    //在构造方法里this()/this(参数)指调用本类其他构造方法,放在首行


    public Employee(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public static void main(String[] args) {
        Employee em=new Employee("员工",18);
        em.say("boss",60);
    }
    public void say(String name,int age){
        say2();//成员方法可以调用静态的
        Employee.say2();
        say0();//成员方法可以调用成员方法
        System.out.println("对"+age+"岁的"+name+"说我的名字是"+this.name+"\t我的年龄是"+this.age);
    }
    public void say0(){

    }
    static void say1(){
        System.out.println("111");
        Employee.say2();//静态方法可以调用静态方法
        say2();
        //say();
        // Non-static method 'say(java.lang.String, int)' cannot be referenced from a static context
        //成员方法不能被静态的调用
    }
    static void say2(){
        System.out.println("222");
    }

}
